
/**
 *\*\file log.h
 *\*\author Nations
 *\*\version v1.0.1
 *\*\copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
 **/
#ifndef __HTTP_CONNECT_H__
#define __HTTP_CONNECT_H__

#define CJSON_USE 0

#define http_server_host  "http://hexiaola.top:8080/hello/"

//#define http_server_host "http://connector.ebyteiot.net:80"
// #define http_server_host "http://112.54.89.224:5601/dtu/connect?"

#define KEY_METHOD "method"         // : "dtu.connect",
#define KEY_SN "sn"                 // : "Wxxxxxxxxxx",
#define KEY_VER "ver"               // : "v1.0",
#define KEY_BIZCONTENT "bizContent" //:
#define KEY_FWVER "fwVer"           // : "FWxxxx-x-xx"
#define KEY_CODE "code"
#define KEY_CONNECTION "connection"
#define KEY_HOST "host"
#define KEY_PORT "port"
#define KEY_KEEPALIVE "keepalive"
#define KEY_CLIENTID "clientid"
#define KEY_USERNAME "username"
#define KEY_PASSWORD "password"
#define KEY_TOPIC "topic"
#define KEY_SUB "sub"
#define KEY_PUB "pub"
#define KEY_QOS "qos"
#define KEY_UART "uart"
#define KEY_BAUD "baud"
#define KEY_PARITY "parity"
#define KEY_DATABIT "databit"
#define KEY_STOPBIT "stopbit"
#define KEY_FLOW "flow"
#define KEY_DATAPERIOD "dataPeriod"

typedef struct
{
    char server_host[65];
    char mqtt_clientid[32];
    char mqtt_username[65];
    char mqtt_password[65];
    char mqtt_topic_publish[65];
    char mqtt_topic_subcribe[65];

    unsigned short server_port;
    unsigned int mqtt_keepalive;
    unsigned char mqtt_subqos;
    unsigned char mqtt_pubqos;

    unsigned char uart_parity;
    unsigned char uart_stopbit;
    unsigned char uart_databit;
    unsigned short dataperiod;
    // unsigned char flow;
    unsigned int uart_baud;
} Devcie_Dtu_Link_Para;

void http_connect_init(void);
int http_requst_encode(void *buffer, int length);
int http_connect_decode(Devcie_Dtu_Link_Para *para, char *data, int length);

#endif /* __LOG_H__ */
